package top.hidoctor.auscultation.net.p;

import android.content.Context;

import com.tang.base.BaseResponse;
import com.tang.base.NetMapEncryptUtils;
import com.tang.net.SuccessConsumer;

import java.util.Map;

import io.reactivex.functions.Consumer;
import top.hidoctor.auscultation.bean.AuditBean;
import top.hidoctor.auscultation.net.PresenterWrapper;
import top.hidoctor.auscultation.net.c.AuditDetailContract;

public class AuditDetailPresenter extends PresenterWrapper<AuditDetailContract.View> implements AuditDetailContract.Presenter {


    public AuditDetailPresenter(Context context, AuditDetailContract.View view) {
        super(context, view);
    }


    @Override
    public void getDetail(String id) {
        mView.showLoading();
        Map<String, Object> map = new NetMapEncryptUtils("").getMaps();
        add(mService.auditDetail(id, map)
                .compose(this.<AuditBean>getTransformer())
                .subscribe(new SuccessConsumer<BaseResponse<AuditBean>>(mView, mContext) {
                    @Override
                    public void onSuccess(BaseResponse<AuditBean> response) {
                        mView.hideLoading();
                        mView.getDetailSuc(response.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        throwable.printStackTrace();
                    }
                }));
    }
}
